package Test6.Operation;

import Test6.BOOK.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperatopn{
    public void work(BookList bookList){
        System.out.println("请输入要归还的图书:");
        Scanner sc = new Scanner(System.in);
        String finding= sc.nextLine();
        int flag =0;
        for (int i = 0; i <bookList.getUsedSize() ; i++) {
            if (finding.compareTo(bookList.getBooks(i).getName())==0){
                if (bookList.getBooks(i).isIsBorrowed()==true){
                    bookList.getBooks(i).setIsBorrowed(false);
                }else{
                    System.out.println("该书已在库中,归还失败!");
                }
                flag = 1;
            }
        }
        if(flag==0){
            System.out.println("没有找到该书,即将退出程序!");
            System.exit(0);
        }
        new OutSystem().outSystem();
    }
}
